﻿using Microsoft.AspNetCore.Authorization;
using Simple.Services.System;

namespace Simple.WebApi.Controllers
{
    /// <summary>
    /// 点赞
    /// </summary>
    [Route("api/DynamicLike/[action]")]
    [ApiController]
    [Authorize]
    public class DynamicLikeController : ControllerBase
    {
        private readonly DynamicLikeService _dynamicLikeService;

        public DynamicLikeController(DynamicLikeService dynamicLikeService)
        {
            _dynamicLikeService = dynamicLikeService;
        }

        /// <summary>
        /// 点赞/取消
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<AppResult> ChangeEnable([FromBody] DynamicLikeInputModel models)
        {
            await _dynamicLikeService.IsLike(models);
            return AppResult.Status200OK($"{(models.IsLike ? "点赞" : "取消")}成功");
        }
    }
}
